<template>
	<view class="withholding">
		<u-navbar title="优惠政策" title-color="#333" back-icon-color="#333"></u-navbar>
		<!-- 阶梯优惠 -->
		<view class="withholding-content" v-if="ErpUserType=='FP'">
		  <view class="withholding-box">
		    <view class="withholding-box-two1">
		      <p>具体阶梯优惠区间分为 <text v-for="(i,ind) of discountYHList" :key="ind"><text>{{i.SETTB400CA00}}-{{i.SETTB400CA01}}</text>；</text>具体每个优惠区间，厂区给予的优惠金额展于如下：</p>
		    </view>
		    <view class="withholding-box-two2" v-for="(item,index) of discountList" :key="index">
		      <text>{{index+1}}.符合区间 {{item.SETTB400CA00}}-{{item.SETTB400CA01}} 优惠原则,厂区优惠如下：</text>
					<view class="list-table">
						<view class="list-table-li" v-for="(items,indexs) of item.list401" :key="indexs">
							<text>{{items.SETTB99CA00}}</text>
							<text>{{items.SETTB401CA00}}</text>
						</view>
					</view>
		    </view>
		  </view>
			<!-- <view class="balanceWSJ" v-if="discountList.length==0">
				<image src="https://xstadmin.oss-cn-beijing.aliyuncs.com/HFcustomer/images/QXY/noData.png" mode="">
			</view> -->
		</view>
		<!-- 等级优惠 -->
		<view class="withholding-content" v-else>
		  <view class="withholding-box">
		    <view class="withholding-box-two1">
					<p>根据您的消费使用情况，您目前在各个厂区的优惠价格如下：</p>
		      
		    </view>
		    <view class="withholding-box-two2">
					<view class="list-table">
						<view class="list-table-li" style="background: rgba(232, 232, 232, .3);">
							<text>厂区</text>
							<text>单价折扣</text>
							<text>整车折扣</text>
							<text>整车优惠</text>
						</view>
						<view class="list-table-li" v-for="(item,index) of discountListHF" :key="index">
							<text style="background:#fff;">{{item.SETTB99CA00}}</text>
							<text>{{item.djkj}}</text>
							<text>{{item.zczk}}%</text>
							<text>{{item.zcyh}}元</text>
						</view>
					</view>
		    </view>
		  </view>
			<!-- <view class="balanceWSJ" v-if="discountListHF.length==0">
				<image src="https://xstadmin.oss-cn-beijing.aliyuncs.com/HFcustomer/images/QXY/noData.png" mode="">
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				discountList:[],
				discountYHList:[],
				discountListHF:[],
			}
		},
		onShow() {
			if(this.ErpUserType=='HF'){
				this.getDiscountDataHF()
			}else if(this.ErpUserType=='FP'){
				this.getDiscountDataFP()
			}
		},
		methods: {
			getDiscountDataHF() {
				uni.showLoading({
					title: '请求中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/orm/ormtb420/selectSettb400ListByORMID',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB400ID: this.userinfo.ORMTB400ID, //一级客户ID
						ORMTB410ID: this.userinfo.ORMTB410ID, //二级客户ID
					},
					success: (res) => {
						// console.log(res);
						if (res.data.code == 200) {
							this.discountListHF = res.data.data;
						} else {
							this.discountListHF = [];
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
						uni.hideLoading();
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			},
			getDiscountDataFP() {
				uni.showLoading({
					title: '请求中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/orm/ormtb420/selectSettb400ByIdList',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB400ID: this.userinfo.ORMTB400ID, //一级客户ID
					},
					success: (res) => {
						// console.log(res);
						if (res.data.code == 200) {
							this.discountYHList = res.data.data.yhlist;
							this.discountList = res.data.data.list;
						} else {
							this.discountYHList = [];
							this.discountList = [];
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
						uni.hideLoading();
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			},
		}
	}
</script>

<style scoped>
	.withholding {
	  width: 100%;
	/*  height: 100%;
	  position: fixed;
	  background: rgba(255, 255, 255, 1); */
	}
	.balanceWSJ {
		padding-top: 200rpx;
	}
	
	.balanceWSJ image {
		display: block;
		margin: 0 auto;
		height: 360rpx;
		width: 43%;
	}

	/* 内容 */
	.withholding-content {
	  width: 100%;
	  /* margin-top: 146rpx; */
	}
	
	.withholding-box {
	  width: 100%;
	  padding: 40rpx 24rpx 0;
	  font-size: 0;
	}
	
	.withholding-box-one {
	  width: 100%;
	  display: flex;
	  flex-direction: row;
	  align-items: center;
	}
	
	.withholding-box-one>text:first-child {
	  width: 30rpx;
	  height: 30rpx;
	  display: inline-block;
	  border: 4rpx solid rgba(0, 161, 241, 1);
	  border-radius: 50%;
	}
	
	.withholding-one-font {
	  font-size: 26rpx;
	  color: rgba(153, 153, 153, 1);
	  margin-left: 20rpx;
	}
	
	.withholding-box-two1 {
	  padding: 0rpx 0 30rpx 50rpx;
	
	}
	
	.withholding-box-two2 {
	  /* padding-top: 30rpx; */
		/* padding: 0 0 30rpx 50rpx; */
		padding: 0 0 30rpx 0;
	}
	
	.withholding-box-two1>p {
	  font-size: 26rpx;
	  color: rgba(51, 51, 51, 1);
		text-indent:2em;
	}
	
	.withholding-box-two2>text {
	  font-size: 24rpx;
	  color: rgba(51, 51, 51, 1);
	}
	.list-table{
		font-size: 24rpx;
		border: 1rpx solid #E8E8E8;
		margin-top: 20rpx;
	}
	.list-table-li{
		display: flex;
		flex-direction: row;
		align-items: center;
		text-align: center;
		line-height: 45rpx;
		border:1rpx solid #E8E8E8 ;
		/* border-top:1rpx solid #E8E8E8 ;
		border-bottom:1rpx solid #E8E8E8 ; */
	}
	.list-table-li text:nth-child(2n){
		/* border-top:1rpx solid #E8E8E8 ;
		border-bottom:1rpx solid #E8E8E8 ; */
	}
	.list-table-li text{
		flex: 1;
		border-left:1rpx solid #E8E8E8 ;
		border-right:1rpx solid #E8E8E8 ;
		padding: 20rpx 0;
	}
	.list-table-li text:first-child{
		background: rgba(232, 232, 232, .3);
		padding: 0 !important;
		
	}
</style>
